package com.example.demo.study.lambda;

import java.util.Random;
import java.util.function.Supplier;

/**
 * Supplier接口返回一个任意范型的值，和Function接口不同的是该接口没有任何参数
 */
public class LambdaSupplier {
    public static void main(String[] args) {
        Supplier<String> f = () ->{
            String base = "abcdefghigklmnopqrstuvwxyz0123456789";
            Random random = new Random();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < 8; i++) {
                int number = random.nextInt(base.length());
                sb.append(base.charAt(number));
            }
            return sb.toString();
        };
        System.out.println(f.get());
    }
}
